#include "mainwindow.h"
#include "ui_mainwindow.h"

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    //创建一个菜单栏
    QMenuBar* menuBar = new QMenuBar();
    this->setMenuBar(menuBar);

    //创建菜单
    QMenu* menu = new QMenu("文件");
    menuBar->addMenu(menu);

    //创建菜单项
    QAction* action1 = new QAction("菜单项1");
    QAction* action2 = new QAction("菜单项2");
    menu->addAction(action1);
    menu->addAction(action2);

    //子菜单
    QMenu* child = new QMenu("子菜单");
    menu->addMenu(child);
    //往子菜单添加菜单项
    QAction* action3 = new QAction("更多");
    child->addAction(action3);

}

MainWindow::~MainWindow()
{
    delete ui;
}

